added value_changed signal which proxies for the adjustment. Cleaned
authorMike Kestner <mkestner@ameritech.net>
Fri, 30 Mar 2001 03:35:47 +0000 (03:35 +0000)
committerMike Kestner <mkestner@src.gnome.org>
Fri, 30 Mar 2001 03:35:47 +0000 (03:35 +0000)
Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>

* gtk/gtkspinbutton.c : added value_changed signal which proxies for the
adjustment. Cleaned redundant preconditions (spin != NULL). Added
inline API function docs.
(gtk_spin_button_new_with_range): New convenience constructor.
(gtk_spin_button_set_increments): New adjustment helper.
(gtk_spin_button_set_range): New adjustment helper.

* gtk/testgtk.c : added test of the new convenince constructor and
value_changed signals.

docs/reference/ChangeLog
2001-03-29  Mike Kestner  <mkestner@ameritech.net>

* gtk/tmpl/gtkspinbutton.html: killed function docs that are now
inline.

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gtk/tmpl/gtkspinbutton.sgml
gtk/gtkspinbutton.c
gtk/gtkspinbutton.h
gtk/testgtk.c
tests/testgtk.c

index 7502ac999f3ceadebb05fa59e80aa5bc96abc60f..9826e81c8a7c6cbe0e598b6ff4a6da19c6e57f51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/gtkspinbutton.c : added value_changed signal which proxies for the
+       adjustment. Cleaned redundant preconditions (spin != NULL). Added
+       inline API function docs.
+       (gtk_spin_button_new_with_range): New convenience constructor.
+       (gtk_spin_button_set_increments): New adjustment helper.
+       (gtk_spin_button_set_range): New adjustment helper.
+
+       * gtk/testgtk.c : added test of the new convenince constructor and
+       value_changed signals.
+
 Thu Mar 29 20:20:38 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): Now we
index 7502ac999f3ceadebb05fa59e80aa5bc96abc60f..9826e81c8a7c6cbe0e598b6ff4a6da19c6e57f51 100644 (file)
@@ -1,3 +1,15 @@
+Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/gtkspinbutton.c : added value_changed signal which proxies for the
+       adjustment. Cleaned redundant preconditions (spin != NULL). Added
+       inline API function docs.
+       (gtk_spin_button_new_with_range): New convenience constructor.
+       (gtk_spin_button_set_increments): New adjustment helper.
+       (gtk_spin_button_set_range): New adjustment helper.
+
+       * gtk/testgtk.c : added test of the new convenince constructor and
+       value_changed signals.
+
 Thu Mar 29 20:20:38 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): Now we
index 7502ac999f3ceadebb05fa59e80aa5bc96abc60f..9826e81c8a7c6cbe0e598b6ff4a6da19c6e57f51 100644 (file)
@@ -1,3 +1,15 @@
+Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/gtkspinbutton.c : added value_changed signal which proxies for the
+       adjustment. Cleaned redundant preconditions (spin != NULL). Added
+       inline API function docs.
+       (gtk_spin_button_new_with_range): New convenience constructor.
+       (gtk_spin_button_set_increments): New adjustment helper.
+       (gtk_spin_button_set_range): New adjustment helper.
+
+       * gtk/testgtk.c : added test of the new convenince constructor and
+       value_changed signals.
+
 Thu Mar 29 20:20:38 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): Now we
index 7502ac999f3ceadebb05fa59e80aa5bc96abc60f..9826e81c8a7c6cbe0e598b6ff4a6da19c6e57f51 100644 (file)
@@ -1,3 +1,15 @@
+Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/gtkspinbutton.c : added value_changed signal which proxies for the
+       adjustment. Cleaned redundant preconditions (spin != NULL). Added
+       inline API function docs.
+       (gtk_spin_button_new_with_range): New convenience constructor.
+       (gtk_spin_button_set_increments): New adjustment helper.
+       (gtk_spin_button_set_range): New adjustment helper.
+
+       * gtk/testgtk.c : added test of the new convenince constructor and
+       value_changed signals.
+
 Thu Mar 29 20:20:38 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): Now we
index 7502ac999f3ceadebb05fa59e80aa5bc96abc60f..9826e81c8a7c6cbe0e598b6ff4a6da19c6e57f51 100644 (file)
@@ -1,3 +1,15 @@
+Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/gtkspinbutton.c : added value_changed signal which proxies for the
+       adjustment. Cleaned redundant preconditions (spin != NULL). Added
+       inline API function docs.
+       (gtk_spin_button_new_with_range): New convenience constructor.
+       (gtk_spin_button_set_increments): New adjustment helper.
+       (gtk_spin_button_set_range): New adjustment helper.
+
+       * gtk/testgtk.c : added test of the new convenince constructor and
+       value_changed signals.
+
 Thu Mar 29 20:20:38 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): Now we
index 7502ac999f3ceadebb05fa59e80aa5bc96abc60f..9826e81c8a7c6cbe0e598b6ff4a6da19c6e57f51 100644 (file)
@@ -1,3 +1,15 @@
+Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/gtkspinbutton.c : added value_changed signal which proxies for the
+       adjustment. Cleaned redundant preconditions (spin != NULL). Added
+       inline API function docs.
+       (gtk_spin_button_new_with_range): New convenience constructor.
+       (gtk_spin_button_set_increments): New adjustment helper.
+       (gtk_spin_button_set_range): New adjustment helper.
+
+       * gtk/testgtk.c : added test of the new convenince constructor and
+       value_changed signals.
+
 Thu Mar 29 20:20:38 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): Now we
index 7502ac999f3ceadebb05fa59e80aa5bc96abc60f..9826e81c8a7c6cbe0e598b6ff4a6da19c6e57f51 100644 (file)
@@ -1,3 +1,15 @@
+Thu Mar 29 21:20:38 2001  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/gtkspinbutton.c : added value_changed signal which proxies for the
+       adjustment. Cleaned redundant preconditions (spin != NULL). Added
+       inline API function docs.
+       (gtk_spin_button_new_with_range): New convenience constructor.
+       (gtk_spin_button_set_increments): New adjustment helper.
+       (gtk_spin_button_set_range): New adjustment helper.
+
+       * gtk/testgtk.c : added test of the new convenince constructor and
+       value_changed signals.
+
 Thu Mar 29 20:20:38 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreemodel.c (gtk_tree_row_ref_reordered_callback): Now we
index 31e9f0ca46bef443d4e8f77d6dfc6a57c1093483..adb6ecdddbb97dc36e6ffc0639f685447fa64690 100644 (file)
@@ -1,3 +1,8 @@
+2001-03-29  Mike Kestner  <mkestner@ameritech.net>
+
+       * gtk/tmpl/gtkspinbutton.html: killed function docs that are now
+       inline.
+
 2001-03-23  Havoc Pennington  <hp@redhat.com>
 
        * gdk/gdk-sections.txt: updates
index 8e82038d75732172372a018c2bee9f06a78c962d..040f725df982bde519d31e24a30e0b7bfafcf798 100644 (file)
@@ -12,37 +12,6 @@ A #GtkSpinButton is an ideal way to allow the user to set the value of some attr
 The main properties of a #GtkSpinButton are through a #GtkAdjustment. See the #GtkAdjustment section for more details about an adjustment's properties.
 </para>
 <para>
-#GtkSpinButton widgets are created with a call to gtk_spin_button_new().
-</para>
-<para>
-The #GtkAdjustment of a spin button can be set or retrieved with a call to gtk_spin_button_set_adjustment() or gtk_spin_button_get_adjustment(), respectively.
-</para>
-<para>
-The number of digits after the decimal point of a spin button can be altered with gtk_spin_button_set_digits().
-</para>
-<para>
-To retrieve values from a spin button, use gtk_spin_button_get_value_as_float() if you require a floating point number, or gtk_spin_button_get_value_as_int() if you require an integer.
-</para>
-<para>
-To set the value of a #GtkSpinButton, use gtk_spin_button_set_value(). To change the update behaviour of a spin button, use gtk_spin_button_set_update_policy().
-</para>
-<para>
-When a spin button reaches it's upper or lower limit, it can either stop spinning, or wrap around and continue spinning from the opposite limit. For example, if five is the upper limit and the lower limit is zero, upon reaching the value five, the spin button can change it's value back to zero and continue spinning upwards.
-This behaviour is set with gtk_spin_button_set_wrap().
-</para>
-<para>
-A border around a spin button's arrows can be created using gtk_spin_button_set_shadow_type().
-</para>
-<para>
-A number may be entered that is invalid, given a spin button's range. An erroneous number can be corrected as soon as the spin button is 'activated' using gtk_spin_button_snap_to_ticks(), which will alter the current value to the nearest step increment. (See #GtkAdjustment for step increments).
-</para>
-<para>
-Because a spin contains a #GtkEntry, alphabetic characters may be entered. These can be ignored by using gtk_spin_button_set_numeric() with a value of TRUE. Then only numeric values, '-' and a decimal point will be accepted.
-</para>
-<para>
-To manually increment or decrement the spin button, use gtk_spin_button_spin(), and to force an update (refresh), use gtk_spin_button_update().
-</para>
-<para>
 <example>
 <title>Using a GtkSpinButton to get an integer.</title>
 <programlisting>
@@ -203,114 +172,6 @@ Creates a new #GtkSpinButton.
 @Returns: a #GtkWidget.
 
 
-<!-- ##### FUNCTION gtk_spin_button_set_adjustment ##### -->
-<para>
-Changes which #GtkAdjustment is associated with a spin button.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@adjustment: a #GtkAdjustment.
-
-
-<!-- ##### FUNCTION gtk_spin_button_get_adjustment ##### -->
-<para>
-Retrieves the #GtkAdjustment used by a given spin button.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@Returns: a #GtkAdjustment.
-
-
-<!-- ##### FUNCTION gtk_spin_button_set_digits ##### -->
-<para>
-Alters the number of decimal places that are displayed in a spin button.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@digits: the number of decimal places.
-
-
-<!-- ##### FUNCTION gtk_spin_button_get_value_as_float ##### -->
-<para>
-Retrieves the current value of a #GtkSpinButton. If the number has no decimal places, it is converted to a float before the function returns.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@Returns: the value of @spin_button as a #gfloat.
-
-
-<!-- ##### FUNCTION gtk_spin_button_get_value_as_int ##### -->
-<para>
-Retrieves the current integer value of a #GtkSpinButton.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@Returns: the value of @spin_button as a #gint.
-
-
-<!-- ##### FUNCTION gtk_spin_button_set_value ##### -->
-<para>
-Sets the value of a spin button.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@value: the new floating point value.
-
-
-<!-- ##### FUNCTION gtk_spin_button_set_update_policy ##### -->
-<para>
-Changes the way a spin button refreshes and updates itself. See %GtkSpinButtonUpdatePolicy for more information.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@policy: the new update policy.
-
-
-<!-- ##### FUNCTION gtk_spin_button_set_numeric ##### -->
-<para>
-Sets how the spin button's #GtkEntry reacts to alphabetic characters. A value of TRUE to @numeric means that all non-numeric characters (except '-' and a decimal point) are ignored.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@numeric: whether letters should be ignored.
-
-
-<!-- ##### FUNCTION gtk_spin_button_spin ##### -->
-<para>
-Performs an explicit 'spin' on a spin button.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@direction: the type of spin to perform.
-@increment: the amount to spin.
-
-
-<!-- ##### FUNCTION gtk_spin_button_set_wrap ##### -->
-<para>
-Sets a spin button's value to the lower limit when it's upper limit is reached, and vice versa.
-</para>
-
-@spin_button: a #GtkSpinButton.
-@wrap: defaults to FALSE, set to TRUE to make the spin button wrap.
-
-
-<!-- ##### FUNCTION gtk_spin_button_set_snap_to_ticks ##### -->
-<para>
-Sets whether a number typed into a spin button should be snapped to the nearest step increment.
-</para>
-
-@spin_button: a #GtkButton.
-@snap_to_ticks: TRUE or FALSE.
-
-
-<!-- ##### FUNCTION gtk_spin_button_update ##### -->
-<para>
-Refreshes a spin button. The behaviour of the update is determined by gtk_spin_button_set_update_policy().
-</para>
-
-@spin_button: a #GtkSpinButton.
-
-
 <!-- ##### MACRO GTK_INPUT_ERROR ##### -->
 <para>
 
index 999be5ac9ef786042c48c3678d35eac7911ab406..9ce969b988dc9798bffc4c31ca3229c8b81e5528 100644 (file)
@@ -64,6 +64,7 @@ enum
 {
   INPUT,
   OUTPUT,
+  VALUE_CHANGED,
   LAST_SIGNAL
 };
 
@@ -248,6 +249,14 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
                    GTK_SIGNAL_OFFSET (GtkSpinButtonClass, output),
                    gtk_marshal_BOOLEAN__VOID,
                    GTK_TYPE_BOOL, 0);
+
+  spinbutton_signals[VALUE_CHANGED] =
+    gtk_signal_new ("value_changed",
+                   GTK_RUN_LAST,
+                   GTK_CLASS_TYPE (object_class),
+                   GTK_SIGNAL_OFFSET (GtkSpinButtonClass, value_changed),
+                   gtk_marshal_VOID__VOID,
+                   GTK_TYPE_NONE, 0);
 }
 
 static void
@@ -1064,6 +1073,9 @@ gtk_spin_button_value_changed (GtkAdjustment *adjustment,
   if (return_val == FALSE)
     gtk_spin_button_default_output (spin_button);
 
+  gtk_signal_emit (GTK_OBJECT (spin_button), 
+                  spinbutton_signals[VALUE_CHANGED]);
+
   gtk_spin_button_draw_arrow (spin_button, GTK_ARROW_UP);
   gtk_spin_button_draw_arrow (spin_button, GTK_ARROW_DOWN);
 }
@@ -1423,6 +1435,51 @@ gtk_spin_button_new (GtkAdjustment *adjustment,
   return GTK_WIDGET (spin);
 }
 
+/**
+ * gtk_spin_button_new_with_range:
+ * @min: Minimum allowable value
+ * @max: Maximum allowable value
+ * @step: Increment added or subtracted by spinning the widget
+ * 
+ * This is a convenience constructor that allows creation of a numeric 
+ * #GtkSpinButton without manually creating an adjustment. The value is 
+ * initially set to the minimum value and a page increment of 10 * @step
+ * is the default. The precision of the spin button is equivalent to the 
+ * precision of @step.
+ * 
+ * Return value: the newly instantiated spin button
+ **/
+GtkWidget *
+gtk_spin_button_new_with_range (gdouble min,
+                               gdouble max,
+                               gdouble step)
+{
+  GtkObject *adj;
+  GtkSpinButton *spin;
+  gint digits;
+
+  g_return_val_if_fail (min < max, NULL);
+  g_return_val_if_fail (step != 0.0, NULL);
+
+  spin = gtk_type_new (GTK_TYPE_SPIN_BUTTON);
+
+  adj = gtk_adjustment_new (min, min, max, step, 10 * step, step);
+
+  if (fabs (step) >= 1.0)
+    digits = 0;
+  else {
+    digits = abs ((gint) floor (log10 (fabs (step))));
+    if (digits > 5)
+      digits = 5;
+  }
+
+  gtk_spin_button_configure (spin, GTK_ADJUSTMENT (adj), step, digits);
+
+  gtk_spin_button_set_numeric (spin, TRUE);
+
+  return GTK_WIDGET (spin);
+}
+
 /* Callback used when the spin button's adjustment changes.  We need to redraw
  * the arrows when the adjustment's range changes, and reevaluate our size request.
  */
@@ -1436,6 +1493,13 @@ adjustment_changed_cb (GtkAdjustment *adjustment, gpointer data)
   gtk_widget_queue_resize (GTK_WIDGET (spin_button));
 }
 
+/**
+ * gtk_spin_button_set_adjustment:
+ * @spin_button: a #GtkSpinButton
+ * @adjustment: a #GtkAdjustment to replace the existing adjustment
+ * 
+ * Replaces the #GtkAdjustment associated with @spin_button.
+ **/
 void
 gtk_spin_button_set_adjustment (GtkSpinButton *spin_button,
                                GtkAdjustment *adjustment)
@@ -1467,20 +1531,34 @@ gtk_spin_button_set_adjustment (GtkSpinButton *spin_button,
     }
 }
 
+/**
+ * gtk_spin_button_get_adjustment:
+ * @spin_button: 
+ * 
+ * Get the adjustment associated with a #GtkSpinButton
+ * 
+ * Return value: the #GtkAdjustment of @spin_button
+ **/
 GtkAdjustment *
 gtk_spin_button_get_adjustment (GtkSpinButton *spin_button)
 {
-  g_return_val_if_fail (spin_button != NULL, NULL);
   g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), NULL);
 
   return spin_button->adjustment;
 }
 
+/**
+ * gtk_spin_button_set_digits:
+ * @spin_button: a #GtkSpinButton
+ * @digits: the number of digits to be displayed for the spin button's value
+ * 
+ * Set the precision to be displayed by @spin_button. Up to 5 digit precision
+ * is allowed.
+ **/
 void
 gtk_spin_button_set_digits (GtkSpinButton *spin_button,
                            guint          digits)
 {
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
   g_return_if_fail (digits < 6);
 
@@ -1493,21 +1571,74 @@ gtk_spin_button_set_digits (GtkSpinButton *spin_button,
     }
 }
 
+/**
+ * gtk_spin_button_set_increments:
+ * @spin_button: a #GtkSpinButton
+ * @step: increment applied for a button 1 press.
+ * @page: increment applied for a button 2 press.
+ * 
+ * Sets the step and page increments for spin_button.  This affects how 
+ * quickly the value changes when the spin button's arrows are activated.
+ **/
+void
+gtk_spin_button_set_increments (GtkSpinButton *spin_button,
+                               gdouble        step,
+                               gdouble        page)
+{
+  g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
+
+  spin_button->adjustment->step_increment = step;
+  spin_button->adjustment->page_increment = page;
+}
+
+/**
+ * gtk_spin_button_set_range:
+ * @spin_button: a #GtkSpinButton
+ * @min: minimum allowable value
+ * @max: maximum allowable value
+ * 
+ * Sets the minimum and maximum allowable values for @spin_button
+ **/
+void
+gtk_spin_button_set_range (GtkSpinButton *spin_button,
+                          gdouble        min,
+                          gdouble        max)
+{
+  g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
+
+  spin_button->adjustment->lower = min;
+  spin_button->adjustment->upper = max;
+}
+
+/**
+ * gtk_spin_button_get_value_as_float:
+ * @spin_button: a #GtkSpinButton
+ * 
+ * Get the value @spin_button represented as a floating point number.
+ * 
+ * Return value: the value of @spin_button
+ **/
 gdouble
 gtk_spin_button_get_value_as_float (GtkSpinButton *spin_button)
 {
-  g_return_val_if_fail (spin_button != NULL, 0.0);
   g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), 0.0);
 
   return spin_button->adjustment->value;
 }
 
+/**
+ * gtk_spin_button_get_value_as_int:
+ * @spin_button: a #GtkSpinButton
+ * 
+ * Get the value @spin_button represented as an integer.
+ * 
+ * Return value: the value of @spin_button
+ **/
 gint
 gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button)
 {
   gdouble val;
 
-  g_return_val_if_fail (spin_button != NULL, 0);
   g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), 0);
 
   val = spin_button->adjustment->value;
@@ -1517,11 +1648,17 @@ gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button)
     return ceil (val);
 }
 
+/**
+ * gtk_spin_button_set_value:
+ * @spin_button: a #GtkSpinButton
+ * @value: the new value
+ * 
+ * Set the value of @spin_button.
+ **/
 void 
 gtk_spin_button_set_value (GtkSpinButton *spin_button, 
                           gdouble        value)
 {
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
 
   if (fabs (value - spin_button->adjustment->value) > EPSILON)
@@ -1536,36 +1673,66 @@ gtk_spin_button_set_value (GtkSpinButton *spin_button,
     }
 }
 
+/**
+ * gtk_spin_button_set_update_policy:
+ * @spin_button: a #GtkSpinButton 
+ * @policy: a #GtkSpinButtonUpdatePolicy value
+ * 
+ * Sets the update behavior of a spin button. This determines whether the
+ * spin button is always updated or only when a valid value is set.
+ **/
 void
 gtk_spin_button_set_update_policy (GtkSpinButton             *spin_button,
                                   GtkSpinButtonUpdatePolicy  policy)
 {
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
 
   spin_button->update_policy = policy;
 }
 
+/**
+ * gtk_spin_button_set_numeric:
+ * @spin_button: a #GtkSpinButton 
+ * @numeric: flag indicating if only numeric entry is allowed. 
+ * 
+ * Sets the flag that determines if non-numeric text can be typed into
+ * the spin button.
+ **/
 void
 gtk_spin_button_set_numeric (GtkSpinButton  *spin_button,
                             gboolean        numeric)
 {
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
 
   spin_button->numeric = (numeric != 0);
 }
 
+/**
+ * gtk_spin_button_set_wrap:
+ * @spin_button: a #GtkSpinButton 
+ * @wrap: a flag indicating if wrapping behavior is performed.
+ * 
+ * Sets the flag that determines if a spin button value wraps around to the
+ * opposite limit when the upper or lower limit of the range is exceeded.
+ **/
 void
 gtk_spin_button_set_wrap (GtkSpinButton  *spin_button,
                          gboolean        wrap)
 {
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
 
   spin_button->wrap = (wrap != 0);
 }
 
+/**
+ * spin_button_get_shadow_type:
+ * @spin_button: a #GtkSpinButton 
+ * 
+ * Convenience function to Get the shadow type from the underlying widget's
+ * style.
+ * 
+ * Return value: the #GtkShadowType
+ **/
 static gint
 spin_button_get_shadow_type (GtkSpinButton *spin_button)
 {
@@ -1576,13 +1743,20 @@ spin_button_get_shadow_type (GtkSpinButton *spin_button)
   return rc_shadow_type;
 }
 
+/**
+ * gtk_spin_button_set_snap_to_ticks:
+ * @spin_button: a #GtkSpinButton 
+ * @snap_to_ticks: a flag indicating if invalid values should be corrected.
+ * 
+ * Sets the policy as to whether values are corrected to the nearest step 
+ * increment when a spin button is activated after providing an invalid value.
+ **/
 void
 gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button,
                                   gboolean       snap_to_ticks)
 {
   guint new_val;
 
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
 
   new_val = (snap_to_ticks != 0);
@@ -1595,6 +1769,15 @@ gtk_spin_button_set_snap_to_ticks (GtkSpinButton *spin_button,
     }
 }
 
+/**
+ * gtk_spin_button_spin:
+ * @spin_button: a #GtkSpinButton 
+ * @direction: a #GtkSpinType indicating the direction to spin.
+ * @increment: step increment to apply in the specified direction.
+ * 
+ * Increment or decrement a spin button's value in a specified direction
+ * by a specified amount. 
+ **/
 void
 gtk_spin_button_spin (GtkSpinButton *spin_button,
                      GtkSpinType    direction,
@@ -1603,7 +1786,6 @@ gtk_spin_button_spin (GtkSpinButton *spin_button,
   GtkAdjustment *adj;
   gdouble diff;
 
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
   
   adj = spin_button->adjustment;
@@ -1665,6 +1847,12 @@ gtk_spin_button_spin (GtkSpinButton *spin_button,
     }
 }
 
+/**
+ * gtk_spin_button_update:
+ * @spin_button: a #GtkSpinButton 
+ * 
+ * Manually force an update of the spin button.
+ **/
 void 
 gtk_spin_button_update (GtkSpinButton *spin_button)
 {
@@ -1672,7 +1860,6 @@ gtk_spin_button_update (GtkSpinButton *spin_button)
   gint error = 0;
   gint return_val;
 
-  g_return_if_fail (spin_button != NULL);
   g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button));
 
   return_val = FALSE;
@@ -1718,3 +1905,4 @@ gtk_spin_button_update (GtkSpinButton *spin_button)
        }
     }
 }
+
index 72ddf47e9b5ce442b58a0a592a2b81c70e2f3a1a..3d1561f444a714e8c3fe86af0d891d8a70837020 100644 (file)
@@ -106,6 +106,7 @@ struct _GtkSpinButtonClass
   gint (*input)  (GtkSpinButton *spin_button,
                  gdouble       *new_value);
   gint (*output) (GtkSpinButton *spin_button);
+  void (*value_changed) (GtkSpinButton *spin_button);
 };
 
 
@@ -120,6 +121,10 @@ GtkWidget* gtk_spin_button_new                (GtkAdjustment  *adjustment,
                                                    gdouble         climb_rate,
                                                    guint           digits);
 
+GtkWidget*     gtk_spin_button_new_with_range     (gdouble  min,
+                                                   gdouble  max,
+                                                   gdouble  step);
+
 void           gtk_spin_button_set_adjustment     (GtkSpinButton  *spin_button,
                                                    GtkAdjustment  *adjustment);
 
@@ -128,6 +133,14 @@ GtkAdjustment*     gtk_spin_button_get_adjustment     (GtkSpinButton  *spin_button);
 void           gtk_spin_button_set_digits         (GtkSpinButton  *spin_button,
                                                    guint           digits);
 
+void           gtk_spin_button_set_increments     (GtkSpinButton  *spin_button,
+                                                   gdouble         step,
+                                                   gdouble         page);
+
+void           gtk_spin_button_set_range          (GtkSpinButton  *spin_button,
+                                                   gdouble         min,
+                                                   gdouble         max);
+
 gdouble                gtk_spin_button_get_value_as_float (GtkSpinButton  *spin_button);
 
 gint           gtk_spin_button_get_value_as_int   (GtkSpinButton  *spin_button);
index b8aa151133ac8c726d743c4d031c587be3dbc31e..cda2d5fec776ef585a43b893a81a0ff07edcc06d 100644 (file)
@@ -3770,6 +3770,23 @@ get_value (GtkWidget *widget, gpointer data)
   gtk_label_set_text (label, buf);
 }
 
+static void
+get_spin_value (GtkWidget *widget, gpointer data)
+{
+  gchar *buffer;
+  GtkLabel *label;
+  GtkSpinButton *spin;
+
+  spin = GTK_SPIN_BUTTON (widget);
+  label = GTK_LABEL (data);
+
+  buffer = g_strdup_printf ("%0.*f", spin->digits,
+                           gtk_spin_button_get_value_as_float (spin));
+  gtk_label_set_text (label, buffer);
+
+  g_free (buffer);
+}
+
 static gint
 spin_button_time_output_func (GtkSpinButton *spin_button)
 {
@@ -4050,6 +4067,22 @@ create_spins (void)
       gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0);
       gtk_label_set_text (GTK_LABEL (val_label), "0");
 
+      frame = gtk_frame_new ("Using Convenience Constructor");
+      gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
+  
+      hbox = gtk_hbox_new (FALSE, 0);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_container_add (GTK_CONTAINER (frame), hbox);
+      
+      val_label = gtk_label_new ("0.0");
+
+      spinner = gtk_spin_button_new_with_range (0.0, 10.0, 0.009);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinner), 0.0);
+      gtk_signal_connect (GTK_OBJECT (spinner), "value_changed",
+                         GTK_SIGNAL_FUNC (get_spin_value), val_label);
+      gtk_box_pack_start (GTK_BOX (hbox), spinner, TRUE, TRUE, 5);
+      gtk_box_pack_start (GTK_BOX (hbox), val_label, TRUE, TRUE, 5);
+
       hbox = gtk_hbox_new (FALSE, 0);
       gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
   
@@ -9342,7 +9375,6 @@ scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
 
   if (!GTK_WIDGET_DRAWABLE (widget))
     return;
-
   gdk_window_scroll (widget->window, 0, dy);
   gdk_window_process_updates (widget->window, FALSE);
 }
index b8aa151133ac8c726d743c4d031c587be3dbc31e..cda2d5fec776ef585a43b893a81a0ff07edcc06d 100644 (file)
@@ -3770,6 +3770,23 @@ get_value (GtkWidget *widget, gpointer data)
   gtk_label_set_text (label, buf);
 }
 
+static void
+get_spin_value (GtkWidget *widget, gpointer data)
+{
+  gchar *buffer;
+  GtkLabel *label;
+  GtkSpinButton *spin;
+
+  spin = GTK_SPIN_BUTTON (widget);
+  label = GTK_LABEL (data);
+
+  buffer = g_strdup_printf ("%0.*f", spin->digits,
+                           gtk_spin_button_get_value_as_float (spin));
+  gtk_label_set_text (label, buffer);
+
+  g_free (buffer);
+}
+
 static gint
 spin_button_time_output_func (GtkSpinButton *spin_button)
 {
@@ -4050,6 +4067,22 @@ create_spins (void)
       gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0);
       gtk_label_set_text (GTK_LABEL (val_label), "0");
 
+      frame = gtk_frame_new ("Using Convenience Constructor");
+      gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
+  
+      hbox = gtk_hbox_new (FALSE, 0);
+      gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+      gtk_container_add (GTK_CONTAINER (frame), hbox);
+      
+      val_label = gtk_label_new ("0.0");
+
+      spinner = gtk_spin_button_new_with_range (0.0, 10.0, 0.009);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinner), 0.0);
+      gtk_signal_connect (GTK_OBJECT (spinner), "value_changed",
+                         GTK_SIGNAL_FUNC (get_spin_value), val_label);
+      gtk_box_pack_start (GTK_BOX (hbox), spinner, TRUE, TRUE, 5);
+      gtk_box_pack_start (GTK_BOX (hbox), val_label, TRUE, TRUE, 5);
+
       hbox = gtk_hbox_new (FALSE, 0);
       gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
   
@@ -9342,7 +9375,6 @@ scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
 
   if (!GTK_WIDGET_DRAWABLE (widget))
     return;
-
   gdk_window_scroll (widget->window, 0, dy);
   gdk_window_process_updates (widget->window, FALSE);
 }